package cn.dkk.behavior_design.momento.white_box;

/**
 * @author dkk
 * @date 2022/7/31
 * @desc
 */
public class GameRole {

    private int vit;

    private int atk;

    private int def;

    /**
     * 保存角色状态功能
     * @return 角色状态
     */
    public RoleStateMemento saveState(){
        return new RoleStateMemento(vit,atk,def);
    }

    public void display(){
        System.out.println("生命值:"+vit);
        System.out.println("攻击力:"+atk);
        System.out.println("防御力:"+def);
    }

    /**
     * 恢复状态
     * @param roleStateMemento
     */
    public void recoverState(RoleStateMemento roleStateMemento){
        this.atk=roleStateMemento.getAtk();
        this.vit=roleStateMemento.getVit();
        this.def=roleStateMemento.getDef();
    }

    public void initState(){
        vit=100;
        atk=100;
        def=100;
    }

    public void fight(){
        vit=0;
        atk=0;
        def=0;
    }

    public int getVit() {
        return vit;
    }

    public void setVit(int vit) {
        this.vit = vit;
    }

    public int getAtk() {
        return atk;
    }

    public void setAtk(int atk) {
        this.atk = atk;
    }

    public int getDef() {
        return def;
    }

    public void setDef(int def) {
        this.def = def;
    }
}
